package JVM相关知识;

/**
 * @author coderFu
 * @create 2021/12/25
 * 动态分派
 */
public class DynamicDispatchDemo {

   static abstract class Pet{
        /**
         * 吃东西的方法
         */
        abstract void eat();
    }

     static  class Dog extends Pet{

        @Override
        void eat() {
            System.out.println("狗狗吃东西");
        }
    }

    static  class Cat extends Pet{

        @Override
        void eat() {
            System.out.println("猫猫吃东西");
        }
    }



    public static void main(String[] args) {

        Pet dog = new Dog();
        Pet cat = new Cat();
        cat.eat();
        dog.eat();
    }
}
